package com.nbufe.combination.demo2;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author Zan
 * @Create 2024/5/6 8:35
 * @ClassName: Organ
 * @Description : 机构类 - 学校 or 分院
 */
public class Organ extends Component {

    private List<Component> componentList = new ArrayList<>();

    public Organ(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    @Override
    public void display() {
        System.out.println(this.name + " : " + this.desc);
        for (Component component : componentList) {
            System.out.print("\t");
            component.display();
        }
    }

    public void add(Component c) {
        componentList.add(c);
    }

    public void remove(Component c) {
        componentList.remove(c);
    }

    public Component getChild(int i) {
        return componentList.get(i);
    }
}
